﻿#region

using System.Collections.Specialized;
using System.Configuration;

#endregion

namespace Jiubang.Util{
    ///<summary>
    ///  对系统System.Configuration的包装
    ///</summary>
    public sealed class ConfigurationHelper{
        private readonly NameValueCollection appSettings;
        private readonly ConnectionStringSettingsCollection connectionStrings;

        ///<summary>
        ///</summary>
        ///<param name = "configuration"></param>
        public ConfigurationHelper(Configuration configuration){
            appSettings = new NameValueCollection(configuration.AppSettings.Settings.Count);
            foreach (KeyValueConfigurationElement setting in configuration.AppSettings.Settings){
                AppSettings.Add(setting.Key, setting.Value);
            }
            connectionStrings = new ConnectionStringSettingsCollection();
            connectionStrings = configuration.ConnectionStrings.ConnectionStrings;
        }

        ///<summary>
        ///</summary>
        public NameValueCollection AppSettings{
            get { return appSettings; }
        }

        ///<summary>
        ///</summary>
        public ConnectionStringSettingsCollection ConnectionStrings{
            get { return connectionStrings; }
        }
    }
}